Running a Docker Container with GUI on Mac OS

  1. Install XQuartz

    brew install xquartz
  2. Run XQuartz

    open -a XQuartz
  3. Allow Network Connections (XQuartz/Preferences)

    • Authenticate connections
    • Allow connections from network clients
  4. Get the Host IP

    IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
  5. SET DISPLAY Environment Variable

    export DISPLAY=$IP:0
  6. Add Path to “xhost” to my zsh-Profile; added this line to .zshrc:

    export PATH=/usr/X11/bin/xhost:$PATH
  7. Added the IP with xhost

    xhost + $IP
  8. Run ROS Noetic from Docker Container (test)

    docker pull osrf/ros:noetic-desktop-full
    docker run -dit --platform linux/amd64 -e DISPLAY=$IP:0 -v /tmp/.X11-unix:/tmp --name ros osrf/ros:noetic-desktop-full
  9. Open ~/.bashrc and add the following lines

    source /opt/ros/noetic/setup.bash

Written by@Miller Shin (SeungRyeol Shin)
Robotics Engineer | ROS | AMR(Autonomous Mobile Robot) | Agricultural Robot | SLAM & Navigation | Robotics Application

InstagramGitHubLinkedIn